<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(
        array(
            'namespace' => '',
            'basePath'  => APPLICATION_PATH
        ));

        
        $autoloader->addResourceTypes(array(
            'App' => array(
                'path'      =>'/library/App/',
                'namespace' => 'App_',
            ),
            'Service' => array(
                'path'      =>'/services/',
                'namespace' => 'Service_',
            ))
        );
        return $autoloader;
    }
    
    protected function _initDb()
    {
        $config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini',
            'develop'
        );
        $db = Zend_Db::factory($config->resources->db);
        $db->query('SET NAMES UTF8');
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        Zend_Registry::set('db' , $db);
        App_Model_Mapper_Abstract::setDefaultAdapter($db);
    }
    protected function _initView()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $layout->setLayout('default');
        $view = $layout->getView();
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
        $view->headTitle('РҐРµР»РёРєСЂР°С„С‚');
        $view->headTitle()->setSeparator(' - ');
    }
    
    protected function _initLogger()
    {
        $logger = new Zend_Log();
        $writer = new Zend_Log_Writer_Firebug();
        $logger->addWriter($writer);
        Zend_Registry::set('logger',$logger);
        $logger = Zend_Registry::get('logger');
        $logger->log('Р­С‚Рѕ С‚РµСЃС‚РѕРІР°СЏ РѕС‚Р»Р°РґРѕС‡РЅР°СЏ РёРЅС„РѕСЂРјР°С†РёСЏ!', Zend_Log::INFO);
        $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
        $profiler->setEnabled(true);
        $db = Zend_Registry::get('db');
        $db->setProfiler($profiler);
    }
}
